<?php
/* @var $this EntryController */
/* @var $model Entry */

$this->breadcrumbs=array(
        $model->code,
);



        $el= EntryLog   ::model()->findAll('entry_id = :a ORDER BY identry_status DESC', array(':a'=>$model->id));
                if (count($el) !== 0){
                $elog;
                foreach ($el as $row) 
                        {
                        $elog = $row->identry_status;
                        
                        }
                        }       





require_once 'Mobile_Detect.php';
	
	

			$detect = new Mobile_Detect;
			
if ($detect->isMobile() ){
?>

<body style="background-image: url( http://i59.tinypic.com/35i0i0z.png )"> </body>


<?php

$this->menu=array(
        
        array('label'=>'Manage Entry', 'url'=>array('admin')),
        array('label'=>'Show Client', 'url'=>array('client/view', 'id'=>$model->client->id)),
        array('label'=>'Show EntryLog', 'url'=>array('entryLog/view', 'id'=>$elog)),
        array('label'=>'Back to Entries', 'url'=>array('index')),
);

 
 } 
 
else
 {
 
 //task_id = 1= Lodger , 2= Shipper

                 $et1= EmployeeTask::model()->findAll('entry_id = :a and task_id=1 OR task_id=2 AND entry_id = :a', array(':a'=>$model->id));
				 $et2= EmployeeTask::model()->findAll('entry_id = :a and task_id=1', array(':a'=>$model->id));
				 $et3= EmployeeTask::model()->findAll('entry_id = :a and task_id=2', array(':a'=>$model->id));
				 $et4= EmployeeTask::model()->findAll('entry_id = :a and task_id=1 OR task_id=2 AND entry_id = :a', array(':a'=>$model->id));
				 
				 
				 
				 /*
				                 foreach ($et4 as $row) 
        { 
      
        
                 
                 echo  'Task: '. CHtml::link($row->task->description, array('employeeTask/view', 'id'=>$row->task_id)); ?>
                <br>
              <?php  
                }
                
				 echo count($et2)."-".count($et3);
                */
				 if (count($et1) == 0){
                                 
                                 

                $this->menu=array(
        //array('label'=>'List Entry', 'url'=>array('index')),
        array('label'=>'Add New Entry', 'url'=>array('create')),
        array('label'=>'Update Entry', 'url'=>array('update', 'id'=>$model->id)),
        //array('label'=>'Delete Entry', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
        array('label'=>'Manage Entry', 'url'=>array('admin')),
        array('label'=>'Show Client', 'url'=>array('client/view', 'id'=>$model->client->id)),
                array('label'=>'Show EntryLog', 'url'=>array('entryLog/view', 'id'=>$elog)),
        array('label'=>'Add Container', 'url'=>array('container/create', 'entry_id'=>$model->id)),
		array('label'=>'Add Item', 'url'=>array('items/create', 'entry_id'=>$model->id)),
        array('label'=>'Update Entry Status', 'url'=>array('update2', 'id'=>$model->id)),
        array('label'=>'Add Lodger', 'url'=>array('employeeTask/create', 'entry_id'=>$model->id,'task_id'=>1)),
        array('label'=>'Add Shipper', 'url'=>array('employeeTask/create', 'entry_id'=>$model->id,'task_id'=>2)),
        array('label'=>'Back to Entries', 'url'=>array('index')),
                );
			//	echo '1';

}
                                
                else {if (count($et2) !=0&&(count($et3) !=0))	{
				
                                 $this->menu=array(
        //array('label'=>'List Entry', 'url'=>array('index')),
        array('label'=>'Add New Entry', 'url'=>array('create')),
        array('label'=>'Update Entry', 'url'=>array('update', 'id'=>$model->id)),
        //array('label'=>'Delete Entry', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
        array('label'=>'Manage Entry', 'url'=>array('admin')),
        array('label'=>'Show Client', 'url'=>array('client/view', 'id'=>$model->client->id)),
                array('label'=>'Show EntryLog', 'url'=>array('entryLog/view', 'id'=>$elog)),
        array('label'=>'Add Container', 'url'=>array('container/create', 'entry_id'=>$model->id)),
		array('label'=>'Add Item', 'url'=>array('items/create', 'entry_id'=>$model->id)),
        array('label'=>'Update Entry Status', 'url'=>array('update2', 'id'=>$model->id)),
        //array('label'=>'Add Lodger', 'url'=>array('employeeTask/create', 'entry_id'=>$model->id,'task_id'=>1)),
		   //     array('label'=>'Add Shipper', 'url'=>array('employeeTask/create', 'entry_id'=>$model->id,'task_id'=>2)),
        array('label'=>'Back to Entries', 'url'=>array('index')),
                );
				
				//echo '2'.count($et4);

                                 }
								 
                                 
                                 
                 else {
				 
				 
				 if (count($et3) == 0) {
                                 
                                 $this->menu=array(
        //array('label'=>'List Entry', 'url'=>array('index')),
        array('label'=>'Add New Entry', 'url'=>array('create')),
        array('label'=>'Update Entry', 'url'=>array('update', 'id'=>$model->id)),
        //array('label'=>'Delete Entry', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
        array('label'=>'Manage Entry', 'url'=>array('admin')),
        array('label'=>'Show Client', 'url'=>array('client/view', 'id'=>$model->client->id)),
                array('label'=>'Show EntryLog', 'url'=>array('entryLog/view', 'id'=>$elog)),
        array('label'=>'Add Container', 'url'=>array('container/create', 'entry_id'=>$model->id)),
		array('label'=>'Add Item', 'url'=>array('items/create', 'entry_id'=>$model->id)),
        array('label'=>'Update Entry Status', 'url'=>array('update2', 'id'=>$model->id)),
        array('label'=>'Add Shipper', 'url'=>array('employeeTask/create', 'entry_id'=>$model->id,'task_id'=>2)),
        array('label'=>'Back to Entries', 'url'=>array('index')),
                );
//echo '3';
                                 }
                                 
               
                
                                 
           if (count($et2) == 0) {                       

                $this->menu=array(
        //array('label'=>'List Entry', 'url'=>array('index')),
        array('label'=>'Add New Entry', 'url'=>array('create')),
        array('label'=>'Update Entry', 'url'=>array('update', 'id'=>$model->id)),
        //array('label'=>'Delete Entry', 'url'=>'#', 'linkOptions'=>array('submit'=>array('delete','id'=>$model->id),'confirm'=>'Are you sure you want to delete this item?')),
        array('label'=>'Manage Entry', 'url'=>array('admin')),
        array('label'=>'Show Client', 'url'=>array('client/view', 'id'=>$model->client->id)),
                array('label'=>'Show EntryLog', 'url'=>array('entryLog/view', 'id'=>$elog)),
        array('label'=>'Add Container', 'url'=>array('container/create', 'entry_id'=>$model->id)),
		array('label'=>'Add Item', 'url'=>array('items/create', 'entry_id'=>$model->id)),
		       array('label'=>'Add Lodger', 'url'=>array('employeeTask/create', 'entry_id'=>$model->id,'task_id'=>1)),
        array('label'=>'Update Entry Status', 'url'=>array('update2', 'id'=>$model->id)),
        array('label'=>'Back to Entries', 'url'=>array('index')),
                );

			//	echo '4';
}
        
}

 
 }
	}

?>

<h1>View Entry: <?php echo $model->code; ?></h1>
        
        

               
                



<?php 



$this->widget('ext.widgets.DetailView4Col', array(
    'data'=>$model,
	'cssFile' => Yii::app()->request->baseUrl .'/css/col4.css',
    'attributes'=>array(
        array(
            'header'=>'Entry Details',
        ),
		 array('label'=>'Date Created', 'value'=>$model->date), 'ETA',
		 'lodge_date', 'customs_entry_no', 'manifest_no',
        array('label'=>'Port', 'value'=>$model->port->name),
                array('label'=>'Shipping Line', 'value'=>$model->shippingLine->name), 'section', 'selectivity', 
				array('label'=>'Status', 'value'=>$model->status->description), 'item', 'final_assement_payment_date',
				'final_assessment',
				
				
		array(
            'header'=>'Bill of Lading Information',
        ),
		 'bill_of_lading_no',
       'wharfage',
				'arrastre',
				'freight', 'insurance', 'container_deposit',
			 'country_of_export',
				'country_of_origin',
	
				'terms_of_delivery',
				'terms_of_payment',
				'vessel_aircraft',
				
				
				array(
            'header'=>'Client Data',
        ),
        array('label'=>'Client', 'value'=>$model->client->name),
			array('label'=>'Client Address', 'value'=>$model->client->address),
                                array('label'=>'Client Mobile no.', 'value'=>$model->client->mobile_no),
                                        array('label'=>'Client Email', 'value'=>$model->client->email),

 
		
		
		
        array(
            'header'=>'Exporter Data',
        ),
       'exporter_name',
				'exporter_address',
				'exporter_tin',

	
	array(
            'header'=>'Bank Data',
        ),
       'bank_code',
				'bank_name',
				'bank_branch', 'bank_reference_no',
				
				
	
    )
));





?>

 
                <?php $et= EmployeeTask::model()->findAll('entry_id = :a', array(':a'=>$model->id));?>
                <?php if (count($et) !== 0){
                $i = 0;
                ?>

                <h1>Employee Task:</h1>
                        
                <?php foreach ($et as $row) 
        { ?>
        <h1>
        <?php
                $i++; 
                 echo  'Task: '. CHtml::link($row->task->description, array('employeeTask/view', 'id'=>$row->id));
                
                
                
                ?>
                

                
                </h1>
                <?php

                $this->widget('zii.widgets.CDetailView', array(
                'data'=>$row,
                'attributes'=>array(
        //      'code',
                //'size',
                //'id',
                //CHtml::link($row->task->description, array('task/view', 'id'=>$row->id)
                //array('label'=>'Task', 'value'=>$row->task->description),
                
                array('label'=>' Name', 'value'=>$row->employee->last_name . ', ' . $row->employee->first_name),
                //      array('label'=>'Last Name', 'value'=>),
                                
                ),
                
                ));
                
                }
        }
 ?>
                <br>
                
                <?php
                ////tabs
                
$this->widget('zii.widgets.jui.CJuiTabs',array(
    'tabs'=>array(
	
        'Containers'=>array('content'=>$this->renderPartial('_containers',
                                        array('eid'=>$model->id),TRUE
                                        )),    
        'Items'=>array('content'=>$this->renderPartial('_items',
                                        array('eid'=>$model->id),TRUE
                                        )),
                                   
                //'Dynamic Tab'=>array('ajax'=>$this->createAbsoluteUrl('baptismal/index')),
    ),
 //  additional javascript options for the tabs plugin
    'options'=>array(
        'collapsible'=>true,
                //'event'=>'mouseover',
    ),
    'id'=>'MyTab-Menu',
));
?>